<link rel="stylesheet" href="<?php echo $this->basePath('public/mobile/default/css/touch.css'); ?>">

<section style="border-top:none;" class="user-order-detail">
    <div class="user-order">
        <p><?php echo $this->translate('订单状态'); ?>：<span><?php echo $this->frontwebsite()->getOneOrderStateInfo($this->order_info->order_state); ?></span></p>
        <p><?php echo $this->translate('订单号'); ?>：<span><?php echo $this->order_info->order_sn; ?></span></p>
        <p><?php echo $this->translate('订单总金额'); ?>：<span><?php echo $this->order_info->currency_symbol . $this->order_info->order_amount . $this->order_info->currency_unit; ?></span></p>
        <p><?php echo $this->translate('下单时间'); ?>：<span><?php echo date("Y".$this->translate('年')."m".$this->translate('月')."d".$this->translate('日')." H".$this->translate('时')."i".$this->translate('分')."s".$this->translate('秒'), $this->order_info->order_time); ?></span></p>
        <?php if($this->order_info->pay_time != '') { ?>
        <p><?php echo $this->translate('付款时间'); ?>：<span><?php echo date("Y".$this->translate('年')."m".$this->translate('月')."d".$this->translate('日')." H".$this->translate('时')."i".$this->translate('分')."s".$this->translate('秒'), $this->order_info->pay_time); ?></span></p>
        <?php } ?>
        <?php if($this->order_info->express_time != '') { ?>
        <p><?php echo $this->translate('发货时间'); ?>：<span><?php echo date("Y".$this->translate('年')."m".$this->translate('月')."d".$this->translate('日')." H".$this->translate('时')."i".$this->translate('分')."s".$this->translate('秒'), $this->order_info->express_time); ?></span></p>
        <?php } ?>
        <?php if($this->order_info->finish_time != '') { ?>
        <p><?php echo $this->translate('完成时间'); ?>：<span><?php echo date("Y".$this->translate('年')."m".$this->translate('月')."d".$this->translate('日')." H".$this->translate('时')."i".$this->translate('分')."s".$this->translate('秒'), $this->order_info->finish_time); ?></span></p>
        <?php } ?>
    </div>
    <?php if ($this->order_info->order_state == 10) { ?>
    <section class="ect-padding-lr ect-padding-tb ect-margin-tb ect-margin-bottom0">
        <div class="pay_show">
            <input type="button" value="<?php echo $this->translate('立即付款'); ?>" onclick="onclik_pay('<?php echo $this->url('m_order/default/order_id', array('action'=>'orderpay', 'order_id'=>$this->order_info->order_id)); ?>')" class="btn btn-info ect-btn-info ect-colorf ect-bg">
        </div>
        <div class="pay_return_show" style="display: none;">
            <div><a href="<?php echo $this->url('m_order/default/order_id', array('action'=>'showorder', 'order_id'=>$this->order_info->order_id)); ?>" class="btn btn-info ect-btn-info ect-colorf ect-bg"><?php echo $this->translate('支付完成'); ?></a></div>
            <hr>
            <div><a href="<?php echo $this->url('m_order/default/order_id', array('action'=>'showorder', 'order_id'=>$this->order_info->order_id)); ?>" class="btn btn-info ect-btn-info ect-colorf ect-bg"><?php echo $this->translate('支付未完成'); ?></a></div>
        </div>
        <script>
            function onclik_pay(url) {
                $('.pay_return_show').css('display', '');
                $('.pay_show').css('display', 'none');
                window.open(url);
            }
        </script>
    </section>
    <?php } ?>
    <?php if ($this->order_info->order_state == 40 and !empty($this->order_info->pay_time) and $this->order_info->refund_state != 1) {
            if(($this->order_info->pay_code == 'alipay' or $this->order_info->pay_code == 'malipay') and $this->order_info->ot_order_state == 25) {
                $orderReceiptUrl = 'https://www.alipay.com/';
            } else {
                $orderReceiptUrl = $this->url('m_order/default/order_id', array('action'=>'orderReceipt', 'order_id'=>$this->order_info->order_id, 'order_state'=>$this->order_info->order_state, 'page'=>$this->page));
            }
        ?>
        <section class="ect-padding-lr ect-padding-tb ect-margin-tb ect-margin-bottom0">
            <div>
                <?php  if($this->order_info->pay_code == 'alipay' and $this->order_info->ot_order_state == 25) { ?>
                <input type="button" value="<?php echo $this->translate('确认收货'); ?>" onclick="window.open('<?php echo $orderReceiptUrl; ?>')" class="btn btn-info ect-btn-info ect-colorf ect-bg">
                <?php } else { ?>
                <form method="post" action="<?php echo $orderReceiptUrl; ?>" onsubmit="return order_confirm();">
                    <input name="order_finish" id="order_finish" type="hidden" value="true" />
                <input type="submit" value="<?php echo $this->translate('确认收货'); ?>" class="btn btn-info ect-btn-info ect-colorf ect-bg">
                </form>
                    <script>
                        function order_confirm() {
                            if(window.confirm('<?php echo $this->translate('您确定要确认收货吗？'); ?>')) {
                                return true;
                            } else {
                                return false;
                            }
                        }
                    </script>
                    <?php } ?>
            </div>
        </section>
    <?php } ?>
    <div class="ect-pro-list">
        <ul>
            <?php foreach ($this->order_goods as $goods_value) { ?>
            <li><a target="_blank" href="<?php echo $this->url('m_goods/default', array('goods_id'=>$goods_value['goods_id'], 'class_id'=>$goods_value['class_id'])); ?>"><img src="<?php echo $this->basePath($this->frontwebsite()->shopGoodsImage($goods_value['goods_image'])); ?>"></a>
                <dl>
                    <dt>
                    <h4 class="title"><a target="_blank" href="<?php echo $this->url('m_goods/default', array('goods_id'=>$goods_value['goods_id'], 'class_id'=>$goods_value['class_id'])); ?>"><?php echo $this->escapeHtml($goods_value['goods_name']); ?></a></h4>
                    <?php
                    if($this->refund_order and !empty($this->refund_order->goods_id_str)) {
                        $goods_id_array = explode(',', $this->refund_order->goods_id_str);
                        if(in_array($goods_value['order_goods_id'], $goods_id_array)) echo ' <strong style="color: red;">('.$this->translate('该商品已经退货').')</strong>';
                    }
                    ?>
                    </dt>
                    <dd style="margin-top: 0;">
                        <b>
                        <?php
                        if($goods_value['goods_extend_info']) {
                            echo str_replace(array('</p>','</strong>','<p>','<strong>'), array('', '', '', ''), $goods_value['goods_extend_info']);
                        }
                        ?>
                        </b>
                    </dd>
                    <dd class="dd-price" style="margin-top: 0;">
                        <b>
                            <?php echo $this->translate('本店售价'); ?>：<?php echo $this->order_info->currency_symbol . $goods_value['goods_shop_price'] . $this->order_info->currency_unit; ?> &nbsp;<?php echo $this->translate('数量'); ?>：<?php echo $goods_value['buy_num']; ?>
                        </b>
                    </dd>
                    <dd class="dd-price" style="margin-top: 0;"><b><?php echo $this->translate('小计'); ?>：<span class="ect-colory"><?php echo $this->order_info->currency_symbol . $goods_value['goods_amount'] . $this->order_info->currency_unit; ?></span></b></dd>
                </dl>
            </li>
            <?php } ?>
            <li class="text-right">
                <p class="ect-margin-tb"><?php echo $this->translate('商品总价'); ?>：<b class="ect-colory"><?php echo $this->order_info->currency_symbol . $this->order_info->goods_amount . $this->order_info->currency_unit; ?></b></p>
                <p class="ect-margin-tb"><?php echo $this->translate('商品运费'); ?>：<b class="ect-colory"><?php echo $this->order_info->currency_symbol . $this->order_info->express_fee . $this->order_info->currency_unit; ?></b></p>
                <p class="ect-margin-tb"><?php echo $this->translate('支付手续'); ?>：<b class="ect-colory"><?php echo $this->order_info->currency_symbol . $this->order_info->pay_fee . $this->order_info->currency_unit; ?></b></p>
                <p class="ect-margin-tb"><?php echo $this->translate('购买优惠'); ?>：<b style="color: #ED145B">-<?php echo $this->order_info->currency_symbol . $this->order_info->buy_pre_fee . $this->order_info->currency_unit; ?></b></p>
                <p class="ect-margin-tb"><?php echo $this->translate('会员优惠'); ?>：<b style="color: #ED145B">-<?php echo $this->order_info->currency_symbol . $this->order_info->user_pre_fee . $this->order_info->currency_unit; ?></b></p>
                <?php if($this->order_info->coupon_pre_fee > 0) { ?>
                    <p class="ect-margin-tb"><?php echo $this->translate('优惠券优惠'); ?>：<b style="color: #ED145B">-<?php echo $this->order_info->currency_symbol . $this->order_info->coupon_pre_fee . $this->order_info->currency_unit; ?></b></p>
                <?php } ?>
                <?php
                if(isset($this->order_amount_log) and !empty($this->order_amount_log)) {
                    foreach($this->order_amount_log as $amount_log) {
                        ?>
                        <p class="ect-margin-tb"><?php echo $amount_log['order_edit_amount_info']; ?>：<b style="color: #ED145B"><?php echo $amount_log['order_edit_amount_type']; ?><?php echo $this->order_info->currency_symbol.$amount_log['order_edit_number']; ?></b></p>
                    <?php } } ?>

                <?php if(isset($this->order_info->integral_buy_price) and $this->order_info->integral_buy_price > 0) { ?>
                    <p class="ect-margin-tb"><?php echo $this->translate('积分购买'); ?>：<b style="color: #ED145B">-<?php echo $this->order_info->currency_symbol . $this->order_info->integral_buy_price . $this->order_info->currency_unit; ?></b></p>
                <?php } ?>
                <p class="ect-margin-tb"><?php echo $this->translate('应付款金额'); ?>：<b class="ect-colory"><?php echo $this->order_info->currency_symbol . $this->order_info->order_amount . $this->order_info->currency_unit; ?></b><br> </p>
            </li>
            <?php if ($this->order_info->integral_num > 0) { ?>
            <li class="text-right">
                <?php echo $this->translate('消费积分'); ?>(<?php if ($this->order_info->integral_rule_info != '') {echo $this->order_info->integral_rule_info . ',&nbsp;';} echo $this->translate('交易完成确认收货后才得到'); ?>)：<b class="ect-colory"><?php echo $this->order_info->integral_num; ?><?php echo $this->translate('积分'); ?></b>
            </li>
            <?php } ?>
            <?php if ($this->order_info->integral_type_2_num > 0) { ?>
                <li class="text-right">
                    <?php echo $this->translate('等级积分'); ?>(<?php if ($this->order_info->integral_type_2_num_rule_info != '') {echo $this->order_info->integral_type_2_num_rule_info . ',&nbsp;';} echo $this->translate('交易完成确认收货后才得到'); ?>)：<b class="ect-colory"><?php echo $this->order_info->integral_type_2_num; ?><?php echo $this->translate('积分'); ?></b>
                </li>
            <?php } ?>
        </ul>
    </div>
    <div style="clear:both;"></div>
</section>

<?php if ($this->order_info->order_state == 10 or ($this->order_info->order_state == 30 and $this->order_info->pay_code == 'hdfk')) { ?>
<div class="ect-padding-tb ect-padding-lr ect-margin-tb text-center">
    <a onclick="if (!confirm('<?php echo $this->translate('您确认要取消该订单吗？取消后此订单将视为无效订单'); ?>')) return false;" href="<?php echo $this->url('m_order/default/order_id', array('action'=>'changestate', 'order_id'=>$this->order_info->order_id, 'order_state'=>0, 'page'=>$this->page)); ?>" class="btn btn-info ect-btn-info ect-colorf"><?php echo $this->translate('取消订单'); ?></a>
</div>
<?php } ?>
<?php if ($this->order_info->order_state == 0) { ?>
    <div class="ect-padding-tb ect-padding-lr ect-margin-tb text-center">
        <a onclick="if (!confirm('<?php echo $this->translate('您确认要删除该订单吗？'); ?>')) return false;" href="<?php echo $this->url('m_order/default/order_id', array('action'=>'delOrder', 'order_id'=>$this->order_info->order_id, 'order_state'=>0, 'page'=>$this->page)); ?>" class="btn btn-info ect-btn-info ect-colorf"><?php echo $this->translate('删除订单'); ?></a>
    </div>
<?php } ?>

<section class="order-detail-info ect-margin-tb  ect-margin-bottom0">
    <ul>
        <li><?php echo $this->translate('支付方式'); ?>：<b><?php echo $this->order_info->pay_name; ?></b></li>
        <?php if ($this->order_info->pay_code == 'xxzf' and $this->order_info->pay_certification != '') { ?>
            <li><?php echo $this->translate('支付证明'); ?>：<b><?php echo $this->escapeHtml($this->order_info->pay_certification); ?></b></li>
        <?php } ?>
    </ul>
</section>

<?php if (isset($this->order_info->invoice_content) and !empty($this->order_info->invoice_content)) { ?>
    <section class="order-detail-info ect-margin-tb  ect-margin-bottom0">
        <ul>
            <li><b><?php echo $this->escapeHtml($this->order_info->invoice_content); ?></b></li>
        </ul>
    </section>
<?php } ?>

<section style="margin-bottom:0;" class="order-detail-info ect-margin-tb">
    <ul>
        <?php if($this->delivery_address) { ?>
            <li><?php echo $this->translate('快递信息'); ?>：<b><?php echo $this->delivery_address->express_name; ?></b></li>
            <?php if ($this->delivery_address->express_number != '') { ?>
                <li><?php echo $this->translate('快递单号'); ?>：<b><?php echo $this->delivery_address->express_number; ?></b></li>
            <?php } ?>
            <li><?php echo $this->translate('收货人姓名'); ?>：<b><?php echo $this->delivery_address->delivery_name; ?></b></li>
            <li><?php echo $this->translate('详细地址'); ?>：<b>
                    <?php
                    echo $this->escapeHtml($this->delivery_address->region_address).', ';
                    $region_array = @explode(' ', $this->delivery_address->region_info);
                    $region_array = array_reverse($region_array);
                    echo $this->escapeHtml(implode(', ', $region_array));
                    ?></b>
            </li>
            <li><?php if($this->delivery_address->mod_phone) {echo $this->translate('手机'). '：' . $this->delivery_address->mod_phone . '&nbsp;&nbsp;'; } if($this->delivery_address->tel_phone) {echo $this->translate('固定电话'). '：' . $this->delivery_address->tel_phone; }?></li>
            <?php if(!empty($this->delivery_address->express_time_info)) { ?>
                <li><?php echo $this->translate('最佳送货时间'); ?>：<b><?php echo $this->delivery_address->express_time_info; ?></b></li>
            <?php } ?>
        <?php } ?>

        <?php if (isset($this->order_info->order_message) and !empty($this->order_info->order_message)) { ?>
        <li><?php echo $this->translate('订单留言'); ?>：<b><?php echo $this->escapeHtml($this->order_info->order_message); ?></b></li>
        <?php } ?>
    </ul>
</section>

<?php if (isset($this->express_state_array)) { ?>
<section class="order-detail-info ect-margin-tb ect-margin-bottom0 user-bottom0">
    <?php if(isset($this->express_state_array['api_type']) and !empty($this->express_state_array['api_type'])) { ?>
        <p><?php echo $this->express_state_array['content']; ?></p>
    <?php } ?>
</section>
<?php } ?>